package com.beidouapp.dao.impl;

import java.util.List;
import java.util.Map;

import com.beidouapp.domain.pojo.User;
import com.beidouapp.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.beidouapp.mapper.EmployeeMapper;
import com.beidouapp.domain.example.EmployeeExample;
import com.beidouapp.domain.pojo.Employee;
import com.beidouapp.domain.vo.OrgRoleEmployeeVO;
import com.beidouapp.dao.EmployeeDao;

@Repository
public class EmployeeDaoImpl extends BaseDaoImpl<Employee> implements EmployeeDao {

    @Autowired
    private EmployeeMapper employeeMapper;

    @Override
    public BaseMapper<Employee> getResourceMapper() {
        return this.employeeMapper;
    }

    @Override
    public Employee getEmployeeByUserId(Long userId) {
        return this.employeeMapper.getEmployeeByUserId(userId);
    }

    @Override
    public List<Employee> findEmployeeListByRoleId(Long roleId){
        return this.employeeMapper.findEmployeeListByRoleId(roleId);
    }

    @Override
    public OrgRoleEmployeeVO getEmployeeVOById(Long empId){
        return this.employeeMapper.getEmployeeVOById(empId);
    }


    //---------------------

    @Override
    public Employee getEmployeeById(Long id) {
        return employeeMapper.getEmployeeById(id);
    }


    @Override
    public int insert(Employee record) {
        return employeeMapper.addEntry(record);
    }

    @Override
    public int updateByPrimaryKeySelective(Employee record) {
        return employeeMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public Employee selectOneByExample(EmployeeExample example) {
        List<Employee> list = employeeMapper.selectByExample(example);
        if (list != null && !list.isEmpty()) {
            return list.get(0);
        }
        return null;
    }


    @Override
    public List<Employee> selectPageByExample(EmployeeExample example) {
        return employeeMapper.selectByExample(example);
    }

    @Override
    public List<OrgRoleEmployeeVO> findOrgRoleEmployeesByMap(Map<String, Object> params, Integer offset, Integer limit) {
        return employeeMapper.findOrgRoleEmployeesByMap(new RowBounds(offset, limit), params);
    }

    @Override
    public Integer findCountOrgRoleEmployees(Map<String, Object> params) {
        return employeeMapper.findCountOrgRoleEmployees(params);
    }


}
